package org.dromara.business.jobhandler;


import cn.hutool.core.date.DateUtil;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.dromara.business.domain.Goods;
import org.dromara.business.service.GoodsService;
import org.springframework.stereotype.Component;


/**
 * 定时任务
 *
 * @author zlj
 * @since 2023/8/10
 */
@Slf4j
@Component
//@EnableScheduling
public class GoodsJobHandler {

    @Resource
    private GoodsService goodsService;

    /**
     * 关闭高于6小时还没收货的订单
     */
    //@Scheduled(cron = "0 0/5 * * * ?")
    public void end() {
        log.info("=========================开始关闭高于6小时还没收货的订单=========================");
        boolean update = goodsService.lambdaUpdate().set(Goods::getStatus, "5")
            .eq(Goods::getStatus, "4")
            .le(Goods::getUpdateTime, DateUtil.offsetHour(DateUtil.date(), -6))
            .update();
        log.info("======================关闭高于6小时还没收货的订单完毕======================");
    }
}
